package com.shihan.rabbitmq.blockingqueuedemo.BlockingQueueMQ;

import java.util.concurrent.BlockingQueue;

/**
 * @Description
 * @Author shihan
 * @Date 2020/12/7 16:46
 * @Version 1.0
 */
public class MyConsumer implements Runnable {

    private final BlockingQueue<MyMessageObj> blockingQueue;

    public MyConsumer(BlockingQueue<MyMessageObj> blockingQueue) {
        this.blockingQueue = blockingQueue;
    }

    @Override
    public void run() {
        while (true){
            MyMessageObj take = null;
            try {
                take = blockingQueue.take();
                System.out.println("消费者：" + take);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
}
